﻿-- quest functions go here
function DailyTracker:GetQuestDb()
	return DailyCategories, DailyQuests
end

function DailyTracker:GetQuestByName( questName )
	categories, quests = self:GetQuestDb();
	for i=1,table.getn(quests) do
		if quests[i].Title == questName then
			return quests[i];
		end
	end
	return nil;
end

function DailyTracker:QuestToString( quest )
	local rv = "";
	rv = rv .. quest.Title;
	
	if quest.Location then
		rv = rv .. " (" .. quest.Location .. ")";
	end
	
	return rv;
end

function DailyTracker:GetQuest( questCategoryId, questId )
	categories, quests = self:GetQuestDb();
	for i=1,table.getn(quests) do
		if quests[i].Id == questId and quests[i].Category == questCategoryId then
			return quests[i];
		end
	end
	return nil;
end

function DailyTracker:GetCategory( questCategoryId )
	categories, quests = self:GetQuestDb();
	for i=1,table.getn(categories) do
		if categories[i].Id == questCategoryId then
			return categories[i];
		end
	end
	return nil;
end

function DailyTracker:SetCurrentQuest( questCategoryId, questId )
	local currentCategory = self:GetCategory( questCategoryId );
	if currentCategory then
		currentCategory.CurrentQuest = questId;
	end
	return nil;
end

function DailyTracker:GetCurrentQuest( questCategoryId )
	local currentCategory = self:GetCategory( questCategoryId );
	if currentCategory then
		return self:GetQuest( questCategoryId, currentCategory.CurrentQuest );
	end
	return nil;
end
